﻿<!--
	========================================================================
	 awzBoxes Library
	
	 Homepage: http://www.awzhome.de/
	========================================================================
	
	This Source Code Form is subject to the terms of the Mozilla Public
	License, v. 2.0. If a copy of the MPL was not distributed with this
	file, You can obtain one at http://mozilla.org/MPL/2.0/.
   
	The Original Code is code of awzBoxes Library.

	The Initial Developer of the Original Code is Andreas Weizel.
	Portions created by the Initial Developer are
	Copyright (C) 2011-2012 Andreas Weizel. All Rights Reserved.
	
	Contributor(s): (none)
	
	========================================================================
-->

<UserControl
	x:Class="AWZhome.awzBoxes.BoxWindowContainer"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	xmlns:box="clr-namespace:AWZhome.awzBoxes"
	xmlns:boxt="clr-namespace:AWZhome.awzBoxes.Tools"
	Loaded="UserControl_Loaded"
	mc:Ignorable="d" 
	d:DesignHeight="408" d:DesignWidth="527">

	<UserControl.CommandBindings>
		<CommandBinding
			Command="box:BoxCommands.BoxAutoHideTrigger"
			CanExecute="BoxAutoHideTriggerCommandBinding_CanExecute"
			Executed="BoxAutoHideTriggerCommandBinding_Executed" />
		<CommandBinding
			Command="box:BoxCommands.AutoHideBoxItemClose"
			CanExecute="AutoHideBoxItemCloseCommandBinding_CanExecute"
			Executed="AutoHideBoxItemCloseCommandBinding_Executed" />
		<CommandBinding
			Command="box:BoxCommands.AutoHideBoxItemRedock"
			CanExecute="AutoHideBoxItemRedockCommandBinding_CanExecute"
			Executed="AutoHideBoxItemRedockCommandBinding_Executed" />
	</UserControl.CommandBindings>

	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="Styles/BoxWindowContainerStyle.Generic.xaml"/>
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
	</UserControl.Resources>

	<Grid Margin="4,4,4,4">
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="*" />
			<ColumnDefinition Width="Auto" />
		</Grid.ColumnDefinitions>

		<!-- Auto-hide button list: Left -->
		<ItemsControl
			x:Name="leftAutoHideButtonList" Grid.Column="0"
			Visibility="Collapsed"
			ItemsSource="{Binding LeftBoxArea.AutoHiddenBoxes}"
			ItemTemplate="{Binding Source={StaticResource AutoHiddenBoxVerticalTemplate}}"
			Style="{Binding Source={StaticResource AutoHideListBoxStyle}}">
			<ItemsControl.ItemsPanel>
				<ItemsPanelTemplate>
					<StackPanel Orientation="Vertical"/>
				</ItemsPanelTemplate>
			</ItemsControl.ItemsPanel>
		</ItemsControl>

		<boxt:SplittedColumnGrid
			x:Name="ColumnLayoutGrid" Grid.Column="1"
			box:BoxWindowContainer.ColumnLayout="True">

			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition Height="*" />
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>

				<!-- Auto-hide button list: Top -->
				<ItemsControl
					box:BoxWindowContainer.TopAutoHideArea="true"
					Grid.Row="0" Visibility="Collapsed"
					ItemsSource="{Binding TopBoxArea.AutoHiddenBoxes}"
					ItemTemplate="{Binding Source={StaticResource AutoHiddenBoxHorizontalTemplate}}"
					Style="{Binding Source={StaticResource AutoHideListBoxStyle}}">

					<ItemsControl.ItemsPanel>
						<ItemsPanelTemplate>
							<StackPanel Orientation="Horizontal" />
						</ItemsPanelTemplate>
					</ItemsControl.ItemsPanel>
				</ItemsControl>

				<boxt:SplittedRowGrid
					Grid.Row="1"
					box:BoxWindowContainer.RowLayout="True">

					<Grid box:BoxWindowContainer.InnerArea="True">

					</Grid>
				</boxt:SplittedRowGrid>

				<!-- Auto-hide button list: Bottom -->
				<ItemsControl
					box:BoxWindowContainer.BottomAutoHideArea="true"
					Grid.Row="2" Visibility="Collapsed"
					ItemsSource="{Binding BottomBoxArea.AutoHiddenBoxes}"
					ItemTemplate="{Binding Source={StaticResource AutoHiddenBoxHorizontalTemplate}}"
					Style="{Binding Source={StaticResource AutoHideListBoxStyle}}">

					<ItemsControl.ItemsPanel>
						<ItemsPanelTemplate>
							<StackPanel Orientation="Horizontal" />
						</ItemsPanelTemplate>
					</ItemsControl.ItemsPanel>
				</ItemsControl>

			</Grid>
		</boxt:SplittedColumnGrid>

		<!-- Auto-hide button list: Right -->
		<ItemsControl
			x:Name="rightAutoHideButtonList" Grid.Column="2"
			Visibility="Collapsed"
			ItemsSource="{Binding RightBoxArea.AutoHiddenBoxes}"
			ItemTemplate="{Binding Source={StaticResource AutoHiddenBoxVerticalTemplate}}"
			Style="{Binding Source={StaticResource AutoHideListBoxStyle}}">

			<ItemsControl.ItemsPanel>
				<ItemsPanelTemplate>
					<StackPanel Orientation="Vertical"/>
				</ItemsPanelTemplate>
			</ItemsControl.ItemsPanel>
		</ItemsControl>

		<!-- Window selection popup, shown on Ctrl+Tab -->
		<Popup Name="boxItemSelectorPopup" StaysOpen="False" Width="350" Height="300" AllowsTransparency="True">
			<Border Margin="0,0,0,0">
				<Border.Effect>
					<DropShadowEffect Color="Silver" />
				</Border.Effect>
				<Border Margin="5,5,5,5" BorderThickness="1" BorderBrush="DarkGray">
					<DockPanel>
						<Grid Background="{x:Static SystemColors.ControlBrush}" DockPanel.Dock="Top" Margin="0,0,0,0" Height="60">
							<Grid.RowDefinitions>
								<RowDefinition />
								<RowDefinition />
							</Grid.RowDefinitions>
							<Grid Grid.Row="0" Margin="13,7,7,7">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="25" />
									<ColumnDefinition Width="*" />
								</Grid.ColumnDefinitions>
								<Image
									Grid.Column="0" Source="{Binding ElementName=boxItemPopupListBox, Path=SelectedValue.Icon}"
									Height="16" Width="16" VerticalAlignment="Top" HorizontalAlignment="Left" />
								<TextBlock
									Grid.Column="1" Text="{Binding ElementName=boxItemPopupListBox, Path=SelectedValue.Title}"
									FontWeight="Bold" VerticalAlignment="Top" HorizontalAlignment="Left" />
							</Grid>
							<TextBlock Grid.Row="1" Margin="13,0,7,7" Text="{Binding Title}" />
						</Grid>
						<Grid Background="{x:Static SystemColors.ControlBrush}" Margin="0,0,0,0">
							<ListBox
								Name="boxItemPopupListBox" Grid.Column="1" BorderThickness="0" Margin="10,10,10,10"
								ScrollViewer.HorizontalScrollBarVisibility="Disabled"
								Focusable="False" ItemContainerStyle="{StaticResource BoxItemListItemStyle}"
								Background="{x:Static SystemColors.ControlBrush}">

								<ListBox.ItemTemplate>
									<DataTemplate>
										<TextBlock Text="{Binding Title}" />
									</DataTemplate>
								</ListBox.ItemTemplate>
							</ListBox>
						</Grid>
					</DockPanel>
				</Border>
			</Border>
		</Popup>

		<!-- Popup for auto-hidden BoxItems -->
		<Popup
			Name="autoHidePopup" StaysOpen="False"
			Height="400" Width="300" AllowsTransparency="False" PopupAnimation="Fade"
			Closed="autoHidePopup_Closed">
			<DockPanel LastChildFill="True">
				<Thumb
					Name="autoHideTopThumb" DockPanel.Dock="Top" DragDelta="autoHideTopThumb_DragDelta"
					Style="{Binding Source={StaticResource AutoHidePopupHorizontalThumbStyle}}" />
				<Thumb
					Name="autoHideLeftThumb" DockPanel.Dock="Left" DragDelta="autoHideLeftThumb_DragDelta"
					Style="{Binding Source={StaticResource AutoHidePopupVerticalThumbStyle}}" />
				<Thumb
					Name="autoHideRightThumb" DockPanel.Dock="Right" DragDelta="autoHideRightThumb_DragDelta"
					Style="{Binding Source={StaticResource AutoHidePopupVerticalThumbStyle}}" />
				<Thumb
					Name="autoHideBottomThumb" DockPanel.Dock="Bottom" DragDelta="autoHideBottomThumb_DragDelta"
					Style="{Binding Source={StaticResource AutoHidePopupHorizontalThumbStyle}}" />
				<Border Style="{Binding Source={StaticResource AutoHidePopupBorderStyle}}" Margin="0,0,0,0">
					<Grid>
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition Height="*" />
						</Grid.RowDefinitions>

						<!-- Definition of title bar (for side bars) -->
						<Label
							Grid.Row="0" Style="{StaticResource AutoHidePopupTitleStyle}"
							Content="{Binding Title}"
							AllowDrop="True" />

						<!-- Container for BoxItem -->
						<Grid Name="autoHidePopupContainer" Grid.Row="1" Margin="0,0,0,0"></Grid>
					</Grid>
				</Border>
			</DockPanel>
		</Popup>
	</Grid>
</UserControl>
